//author Dreena Biswas

package view;
import model.*;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;

public class View extends JFrame {


	public static JButton addButton;
	public static JButton deleteButton;
	public static JButton editButton;
	public static JButton sortName;
	public static JButton displayButton;
	public static JButton sortGroup;
	public static JButton sortDate;
	public static JButton refresh;
	public static JList list;
	public static JScrollPane scrollPane;
	
	
	
	public String name;
	
	public View() throws IOException{
		
		addButton = new JButton("Add");
		deleteButton = new JButton("Delete");
		editButton = new JButton("Edit");
		sortName = new JButton("Sort by First Alphabet");
		displayButton = new JButton("Display Contacts");
		sortDate = new JButton("Sort by date");
		sortGroup = new JButton("Sort by group");
		refresh = new JButton("Refresh List");
		JPanel calcPanel = new JPanel();
		JPanel calcPanel1 = new JPanel();
		
		scrollPane = new JScrollPane();
		scrollPane.setPreferredSize(new Dimension(200, 200));
		
		
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(850, 300);
		
		calcPanel.add(refresh,0,0);
		calcPanel.add(addButton);
		calcPanel.add(deleteButton);
		calcPanel.add(editButton);
		calcPanel.add(displayButton);
		calcPanel.add(sortName);
		calcPanel.add(sortGroup);
		calcPanel.add(sortDate);
		
		
		this.add(calcPanel, BorderLayout.WEST);
		//this.add(calcPanel1, BorderLayout.SOUTH);
		
		
		Model obj = new Model(); 
		list = new JList(Model.displayAllContact().toArray());
		list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		scrollPane.setViewportView(list);
		//scrollPane.setSize(100, 300);
		this.add(scrollPane, BorderLayout.SOUTH);
		
	}
	
	// If the addButton is clicked execute a method
		// in the Controller named actionPerformed

		
}
